<template>
  <div class="box">
    <ul class="time">
      <li>
        <p>下单时间</p>
        <span>{{ list.time }}</span>
      </li>
      <li v-if="list.state === 1">
        <p>付款时间</p>
        <span>{{ list.time }}</span>
      </li>
      <li>
        <span class="back" @click="back">返回</span>
      </li>
    </ul>
    <div>
      <Orderstate :list="list"/>
    </div>
    <div class="userdetail">
      <p class="buyer">买家信息</p>
      <div class="buyer-msg">
        <p>
          <span>用户昵称：{{ list.username }}(账号)</span>
        </p>
        <p>
          <span>支付方式：{{ list.pay_method }}(交易流水号)</span>
        </p>
        <p>
          <span>收货地址：{{ list.tel }}</span>
          <span>{{ list.area }}</span>
        </p>
      </div>
    </div>
    <div>
      <Orderdetail :list="list"/>
    </div>
  </div>
</template>

<script>
import Orderstate from '@/components/Order/order_state'
import Orderdetail from '@/components/Order/order_detail'
import { createNamespacedHelpers } from "vuex";
const { mapState } = createNamespacedHelpers("order");
export default {
  data() {
    return {
      list: [],
      id: null,
    };
  },
  components:{
    Orderstate,
    Orderdetail
  },
  methods: {
    //返回
    back(){
      window.history.back()
    }
  },
  mounted() {
    let id_num = this.$route.params.id;
    this.id = this.id_num;
    this.list = this.orderList.filter((item) => item.ord_num === id_num)[0];
    
  },
  computed: {
    ...mapState({
      orderList: (state) => state.orderList,
    }),
  },
};
</script>

<style scoped>
.box {
  width: 95%;
  margin: 20px auto;
  font-size: 12px;
}
.time {
  width: 95%;
  margin: 20px auto;
  display: flex;
  position: relative;
}
.time li {
  width: 15%;
  margin-right: 10px;
}
.time p {
  margin: 10px 0;
}
.userdetail{
  width: 95%;
  margin: 20px auto;
  border: 1px solid lightgray;
  padding: 20px;
  box-sizing: border-box;
}
.buyer{
  width: 100%;
  padding-bottom: 20px;
  border-bottom: 1px solid gray;
  font-size: 16px;
  font-weight: bold;
  color: #666;
}
.buyer-msg {
  margin: 20px 0;
  line-height: 30px;
}
.back{
  display: inline-block;
  cursor: pointer;
  position: absolute;
  right: 0;
  top: 12px;
  width: 60px;
  text-align: center;
  line-height: 30px;
  background: skyblue;
  color: white;
  border-radius: 15px;
}
</style>